﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Entity;
using BO;

namespace Final_Prototype_UsingDev_QuanLy_071012
{
    public partial class Form_Login : Form
    {
        LoginBO lBO = new LoginBO();
        StaffBO sBO = new StaffBO();

        public delegate void PassUserInfo(UserEntity user);
        public delegate void PassStaffInfo(StaffEntity staff);

        UserEntity userinfo = new UserEntity();
        StaffEntity staffinfo = new StaffEntity();
        public Form_Login()
        {
            InitializeComponent();
        }

        private void textEdit1_EditValueChanged(object sender, EventArgs e)
        {

        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {        
            string user=txtUserName.Text;
            string pass =txtPass.Text;
            if (lBO.ValidateLogin(user, pass))
            {
                userinfo = lBO.LoadUserInfo(user);
                
                MessageBox.Show("You logged with " + userinfo.GroupName + " permission");              
                Main fr = new Main();
                PassUserInfo data = new PassUserInfo(fr.ReceiveUserInfo);
                data(userinfo);
                fr.Show();
                
            }
            else
                MessageBox.Show("Your account is invalid!");                       
                   
        }

        private void Form_Login_Load(object sender, EventArgs e)
        {

        }
    }
}
